//
//  HSYFlipView.m
//  高仿暴走斗图
//
//  Created by key on 16/4/27.
//  Copyright © 2016年 huangsongyao. All rights reserved.
//

#import "HSYFlipView.h"
#import "UIView+Gesture.h"

@interface HSYFlipView ()<UIGestureRecognizerDelegate>

@property (nonatomic, strong) UIView *alphaView;
@end

@implementation HSYFlipView

- (instancetype)initWithFrame:(CGRect)frame {
    
    if (self = [super initWithFrame:frame]) {
     
        [self setup];
    }
    return self;
}


- (void)setup {
    
    self.backgroundColor = [UIColor clearColor];
    
    self.alphaView = [NSObject createViewWithBgColor:[UIColor clearColor]];
    self.alphaView.alpha = 1.0f;
    self.alphaView.frame = self.bounds;
    [self addSubview:self.alphaView];
    
    
    UIImageView *image = [NSObject createImgWithImage:[UIImage imageNamed:@"avatar_holder"]
                                               hImage:[UIImage imageNamed:@"avatar_holder"]
                                        clipsToBounds:YES
                                              vcModel:UIViewContentModeScaleToFill];
    image.frame = self.alphaView.bounds;
    [self.alphaView addSubview:image];
    
    UIImageView *transImage = [NSObject createImgWithImage:[UIImage imageNamed:@"launch_load2"]
                                                    hImage:[UIImage imageNamed:@"launch_load2"]
                                             clipsToBounds:YES
                                                   vcModel:UIViewContentModeScaleToFill];
    transImage.frame = self.alphaView.bounds;
    transImage.transform = CGAffineTransformMakeScale(1.0, 1.0);
    [image addSubview:transImage];
}

- (void)animationInImageView:(UIImageView *)imageView tddd:(UIImageView *)tddd {
    
//    [UIView animateWithDuration:1.0 * 10 animations:^{
//        
//        imageView.transform = CGAffineTransformMakeScale(-1.0, 1.0);
//    } completion:^(BOOL finished) {
//        
//    }];
    
    
    [[HSYAnimationHelper shareInstance] customSystemAnimationWithType:kSystemAnimationTypeCameraIrisHollowClose withLayer:imageView.layer duration:10.0 subtype:HSYCustomViewAnimationSubtypeFromBottom key:nil compaletion:^{
        
        [tddd removeFromSuperview];
    }];
}
- (void)animationInView:(UIView *)view {
    
    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
    [UIView setAnimationDuration:1.0 * 10];
    [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:view cache:YES];
    [UIView setAnimationDelegate:self];
    [UIView commitAnimations];
    
    
}

@end
